<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加案例</title>
<link href="${pageContext.request.contextPath }/css/main.css" type="text/css" rel="stylesheet"></link>
<link href="${pageContext.request.contextPath }/css/styles.css" rel="stylesheet" type="text/css" />
 <link href="${pageContext.request.contextPath }/css/facebox.css" rel="stylesheet" type="text/css" />
 <link href="${pageContext.request.contextPath }/css/common.css" rel="stylesheet" type="text/css" />
<script src="${pageContext.request.contextPath }/js/jquery-1.7.2.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function () { 
    new uploadPreview({ UpBtn: "upload", DivShow: "imgdiv", ImgShow: "imgShow" });
}


function getFullPath(obj) {
	//得到图片的完整路径
	if (obj) {
		//ie
		if (window.navigator.userAgent.indexOf("MSIE") >= 1) {
			obj.select();
			return document.selection.createRange().text;
			}
		//firefox
		else if (window.navigator.userAgent.indexOf("Firefox") >= 1) {
			if (obj.files) {
				return obj.files.item(0).getAsDataURL();
				}
			return obj.value;
			}
		return obj.value;
		}
	} 
$(document).ready(function(){
	
	$("#upload").change(function(){
		var strSrc = $("#upload").val();
		
		/* img = new Image();
		img.src = getFullPath(strSrc); */
		//验证上传文件格式是否正确
		var pos = strSrc.lastIndexOf(".");
		var lastname = strSrc.substring(pos, strSrc.length);
		if (lastname != ".jpg" && lastname != ".png" && lastname != ".gif") {
			alert("您上传的文件类型为" + lastname + "，图片必须为 jpg或png或gif类型");
		}
	});
	$("#Company_Name").blur(function(){
		
		if($("#Company_Name").val() == ""){
			
			$("#company_NameError").text("公司名称不能为空。");
		}else{
			$("#company_NameError").text("");
		}
	});
$("#Product_Name").blur(function(){
		
		if($("#Product_Name").val() == ""){
			
			$("#Product_NameError").text("产品名称不能为空。");
		}else{
			$("#Product_NameError").text("");
		}
	});
$("#advantage").blur(function(){
		
		if($("#advantage").val() == ""){
			
			$("#advantageError").text("产品标题不能为空。");
		}else{
			$("#advantageError").text("");
		}
	});
$("#Brief_Introduction").blur(function(){
	
	if($("#Brief_Introduction").val() == ""){
		
		$("#Brief_IntroductionError").text("产品简介不能为空。");
	}else{
		$("#Brief_IntroductionError").text("");
	}
});
$("#Office_Phone").blur(function(){
	
	if($("#Office_Phone").val() == ""){
		
		$("#Office_PhoneError").text("办公电话不能为空。");
	}else{
		if($("#Office_Phone").val().search(/^\d+$/g) == -1){
			
			$("#Office_PhoneError").text("电话号码必须为数字。");
		}
		$("#Office_PhoneError").text("");
	}
});
$("#Address").blur(function(){
	
	if($("#Address").val() == ""){
		
		$("#AddressError").text("公司地址不能为空。");
	}else{
		$("#AddressError").text("");
	}
});
	$("#sub").click(function(){
		
		if($("#Company_Name").val() == ""){
			
			alert("公司名称不能为空。");
			return false;
		}else if($("#Product_Name").val() == ""){
			
			alert("产品名称不能为空。");
			return false;
			
		}else if($("#advantage").val() == ""){
			
			alert("产品标题不能为空。");
			return false;
			
		}else if($("#Brief_Introduction").val() == ""){
			
			alert("产品简介不能为空。");
			return false;
		}else if($("#Office_Phone").val() == ""){
			
			alert("办公电话不能为空。");
			return false;
		}else if($("#Address").val() == ""){
			
			alert("公司地址不能为空。");
			return false;
		}
		if($("#upload").val() == ""){
			alert("图片不能为空。");
			return false;
		}else{
			
		var strSrc = $("#upload").val();
		img = new Image();
		img.src = getFullPath(strSrc);
		var pos = strSrc.lastIndexOf(".");
		
		var lastname = strSrc.substring(pos, strSrc.length);
		
		if (lastname != ".jpg" && lastname != ".png" && lastname != ".gif") {
			alert("您上传的文件类型为" + lastname + "，图片必须为 jpg或png或gif类型");
			return false;
		}  
		}
		if($("#Office_Phone").val() != ""){
			
			if($("#Office_Phone").val().search(/^\d+$/g) == -1){
				
					alert("办公电话必须为数字。");
					return false;
				}
			}
	});
});
</script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.min.js"></script>
    <!-- MASTER STYLESHEET-->
    <link href="${pageContext.request.contextPath }/css/styles.css" rel="stylesheet" type="text/css" />
    
    <!-- LOAD TIPSY TOOLTIPS-->
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.tipsy.js"></script>
   
    <!-- LOAD CUSTOM JQUERY SCRIPTS-->
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/scripts.js"></script>	
    
	 <!-- LOAD FACEBOX -->
	<script type="text/javascript" src="${pageContext.request.contextPath }/js/facebox.js"></script>
    <link href="${pageContext.request.contextPath }/css/facebox.css" rel="stylesheet" type="text/css" />
    

    <!-- LOAD FLOT GRAPHS -->
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.flot.pack.js"></script>
    <!--[if IE]>
     <script language="javascript" type="text/javascript" src="js/excanvas.pack.js"></script>
    <![endif]-->
    
    
    <!--[if IE 6]>
    <script src="js/pngfix.js"></script>
    <script>
        DD_belatedPNG.fix('.png_bg');
    </script>        
    <![endif]-->

	
    <!-- LOAD GRAPH JAVASCRIPT FILE-->
	<script src="${pageContext.request.contextPath }/js/graphs.js" type="text/javascript"></script>
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script src="${pageContext.request.contextPath }/js/uploadPreview.js" type="text/javascript"></script>
<style type="text/css">
#preview{width:260px;height:190px;border:1px solid #000;overflow:hidden;}
#imghead {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image);}
body { overflow-x: hidden; overflow-y: auto; } 
</style>

</head>
<body>
	<div class="result-wrap" style="margin-left: 10%;">
            <form action="${pageContext.request.contextPath }/case/addCase.action" method="post" enctype="multipart/form-data">
                <div class="config-items">
                    <div class="config-title">
                        <h1 style="font-size: 26px;font-family: Tahoma,Geneva,sans-serif;color: #666;">添加案例内容</h1>
                    </div>
                    <div class="result-content">
                        <table width="100%" class="insert-tab">
                            <tr>
                                <th width="20%"><i class="require-red">*</i>案例类型：</th>
                                <td>
                                	<select name="Type" class="common-text" style="width: 625px;">
                                	<s:iterator value="#request.list">
                                		<option><s:property value="business_Type.Type_Name"/>-<s:property value="Type_Name"/></option>
                                	</s:iterator>
                                	</select>
                                </td>
                            </tr>
                            <tr>
                                <th width="15%"><i class="require-red">*</i>公司名称：</th>
                                <td><input type="text" id="Company_Name" name="Company_Name" value="" size="85" class="common-text">
                                	<font id="company_NameError" color="red"></font>
                                </td>
                            </tr>
                            <tr>
                                <th width="15%"><i class="require-red">*</i>产品名称：</th>
                                <td><input type="text" id="Product_Name" name="Product_Name" value="" size="85" class="common-text">
                                <font id="Product_NameError" color="red"></font></td>
                            </tr>
                            <tr>
                                <th width="15%"><i class="require-red">*</i>产品标题：</th>
                                <td><input type="text" id="advantage" name="advantage" value="" size="85" class="common-text">
                                <font id="advantageError" color="red"></font></td>
                            </tr>
                            <tr>
                                <th width="15%"><i class="require-red">*</i>简介：</th>
                                <td>
                                <textarea cols="6" rows="3" id="Brief_Introduction" name="Brief_Introduction" class="wysiwyg"></textarea>
                                <!-- <input type="text" id="Brief_Introduction" name="Brief_Introduction" value="" size="85" class="common-text"> -->
                                <font id="Brief_IntroductionError" color="red"></font></td>
                            </tr>
                            <tr>
                                <th width="15%"><i class="require-red">*</i>办公电话：</th>
                                <td><input type="text" id="Office_Phone" name="Office_Phone" value="" size="85" class="common-text">
                                <font id="Office_PhoneError" color="red"></font></td>
                            </tr>
                            <tr>
                                <th width="15%"><i class="require-red">*</i>公司地址：</th>
                                <td><input type="text" id="Address" name="Address" value="" size="85" class="common-text">
                                <font id="AddressError" color="red"></font></td>
                            </tr>
                            <tr>
                                <th width="15%"><i class="require-red">*</i>是否发布：</th>
                                <td>
                  					<select style="width: 625px;" name="IsPublish" class="common-text">
                  						<option value="false">否</option>
                            		<option value="true">是</option>
                  					</select>              
                                </td>
                            </tr>
                            <tr>
                                	<th></th>
                                	<th align="left"><div id="imgdiv" align="left"><img id="imgShow" width="100" height="100" /></div></th>
                                </tr>
                                 <tr>
                                    <th><i class="require-red">*</i>上传图片：</th>
                                    <td><input style="width: 64%" type="file" id="upload" size="85" name="upload" class="common-text">
                                    <span style="color: red;font-size: 12px;">请选择jpg或png格式的图片</span></td>
                                </tr>
                                <tr>
                                    <th></th>
                                    <td>
                                        <input type="submit" id="sub" value="提交" class="btn btn-primary btn6 mr10">
                                        <input type="button" value="返回" onclick="history.go(-1)" class="btn btn6">
                                    </td>
                                </tr>
                            </table>
                    </div>
				</div>
			</form>
		</div>
</body>
</html>